package com.jair.business.controller;

import com.jair.apicommon.service.InterfaceInvokeService;
import com.jair.common.reponse.BaseResponse;
import com.jair.common.utils.ResultUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/health")
@Slf4j
public class HealthController {

    @DubboReference(version = "1.0.0", group = "dev")
    private InterfaceInvokeService interfaceInvokeService;

    @GetMapping("/check")
    public BaseResponse<String> healthCheck() {
        try {
            String result = interfaceInvokeService.healthCheck();
            return ResultUtils.success(result);
        } catch (Exception e) {
            log.error("健康检查失败", e);
            return ResultUtils.error(500, "服务异常");
        }
    }
}
